//index.js
//获取应用实例
const app = getApp()
const http=require('../../modules/HTTP')
Page({
  data: {
    subjects:[],
    start:0
  },
  onLoad(){
    var This=this;
    (async function(){
      var res=await http.getData(This.data.start);
      
      console.log(res);
      subjects=res.data.subjects
      This.setData({
        subjects
      })
    })()
  },
  handleContent:function(event){
    let id=event.currentTarget.dataset.id;
    let pic=escape(event.currentTarget.dataset.pic)
    wx.navigateTo({
      url:'/pages/content/content?id='+id+'&pic='+pic,
    })
  },
  onReachBottom(){
    var This=this;
    var start=this.data.start;
    start+=20;
    (async function(){
      var res=await http.getData(start);
      var {subjects}=res.data;
      This.setData({
        start,
       subjects:This.data.subjects.concat(subjects)
      })
    })()
  }

})
